<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
  		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>网站后台管理模版</title>
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/admin/layui/css/layui.css"/>
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/admin/css/admin.css"/>
	</head>
	<body>
		<div class="layui-tab page-content-wrap">
		  <ul class="layui-tab-title">
		    <li class="layui-this">修改资料</li>
		    <!-- <li>修改密码</li> -->
		  </ul>
		  <div class="layui-tab-content">
		    <div class="layui-tab-item layui-show">
		    	<form class="layui-form"  style="width: 90%;padding-top: 20px;">
				  <div class="layui-form-item">
				    <label class="layui-form-label">ID：</label>
				    <div class="layui-input-block">
				      <input type="text" name="managerId" disabled autocomplete="off" class="layui-input layui-disabled" value="${manager.managerId}">
				    </div>
				  </div> 
				  <div class="layui-form-item">
				    <label class="layui-form-label">用户名：</label>
				    <div class="layui-input-block">
				      <input type="text" id="managerName" name="managerName" lay-verify="required" class="layui-input" value="${manager.managerName}">
				    </div>
				  </div>
				   <!-- <div class="layui-form-item">
				    <label class="layui-form-label">姓名：</label>
				    <div class="layui-input-block">
				      <input type="text" name="name" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input" value="未知">
				    </div>
				  </div>
				  <div class="layui-form-item">
				    <label class="layui-form-label">邮箱：</label>
				    <div class="layui-input-block">
				      <input type="text" name="email" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input" value="52345678@qq.com">
				    </div>
				  </div>
				  <div class="layui-form-item layui-form-text">
				    <label class="layui-form-label">备注：</label>
				    <div class="layui-input-block">
				      <textarea name="desc" placeholder="请输入内容" class="layui-textarea"></textarea>
				    </div>
				  </div> -->
				  <div class="layui-form-item">
				    <div class="layui-input-block">
				      <button class="layui-btn layui-btn-normal" lay-submit lay-filter="adminInfo">立即提交</button>
				    </div>
				  </div>
				</form>
		    </div>
		    <%-- <div class="layui-tab-item">
		    	<form class="layui-form" v style="width: 90%;padding-top: 20px;">
				  <div class="layui-form-item">
				    <label class="layui-form-label">用户名：</label>
				    <div class="layui-input-block">
				      <input type="text" name="managerName" disabled autocomplete="off" class="layui-input layui-disabled" value="${manager.managerName}">
				    </div>
				  </div>
				  <div class="layui-form-item">
				    <label class="layui-form-label">旧密码：</label>
				    <div class="layui-input-block">
				      <input type="password" id="password1" name="password1" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
				    </div>
				  </div>
				  <div class="layui-form-item">
				    <label class="layui-form-label">新密码：</label>
				    <div class="layui-input-block">
				      <input type="password" id="password2" name="password2" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
				    </div>
				  </div>
				  <div class="layui-form-item">
				    <label class="layui-form-label">重复密码：</label>
				    <div class="layui-input-block">
				      <input type="password" id="password3" name="password3" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
				    </div>
				  </div>
				  <div class="layui-form-item">
				    <div class="layui-input-block">
				      <button class="layui-btn layui-btn-normal" lay-submit lay-filter="adminPassword">立即提交</button>
				    </div>
				  </div>
				</form>
		    </div> --%>
		  </div>
		</div>
	<script src="${pageContext.request.contextPath}/static/admin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
	<script>
		//Demo
		layui.use(['jquery', 'form','element'], function(){
		  var form = layui.form();
		  var element = layui.element();
		  var $ =layui.jquery;
		  form.render();
		//自定义验证规则
			form.verify({
				managerName: function(value, item){ //value：表单的值、item：表单的DOM对象
				    if(!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)){
				      return '用户名不能有特殊字符';
				    }
				    if(/(^\_)|(\__)|(\_+$)/.test(value)){
				      return '用户名首尾不能出现下划线\'_\'';
				    }
				    if(/^\d+\d+\d$/.test(value)){
				      return '用户名不能全为数字';
				    }
				    if(/^\d+\d+\d$/.test(value)){
					      return '用户名不能全为数字';
					}
				    if("${manager.managerName}" == value){
					      return '用户名为改变';
					}
				  },
				  
				  //我们既支持上述函数式的方式，也支持下述数组的形式
				  //数组的两个值分别代表：[正则匹配、匹配不符时的提示文字]
				  password1: [
				    /^[\S]{6,12}$/
				    ,'密码必须6到12位，且不能出现空格'
				  ] ,
				  password2: [
					    /^[\S]{6,12}$/
					    ,'密码必须6到12位，且不能出现空格'
				  ], 
				  password3: [
					    /^[\S]{6,12}$/
					    ,'密码必须6到12位，且不能出现空格'
				 ] 
			});
		  //监听信息提交
		  form.on('submit(adminInfo)', function(data){
				//ajax请求实现访问控制器
					$.ajax({
						type : "put", //提交方式
						url : "${pageContext.request.contextPath}/manager/update", ////地址和springmvc中控制器地址一致
						data : JSON.stringify({
							managerId:"${manager.managerId}",
							managerName:$("#managerName").val()
						}), //提交给控制器的数据
						contentType : "application/json", //提交给控制的数据 格式
						dataType:"json",
						success : function(cm) {
							layer.msg(cm.msg);
							parent.location.reload();
					},
		  });
			return false;
		  });
		  /* //监听密码提交
		   form.on('submit(adminPassword)', function(data){
			   
			  if ($("#password1").val() == ${manager.managerId}) {
				  
				  if ($("#password2").val()!=$("#password1").val()) {
					  
					  if ($("#password3").val()!=$("#password2").val()) {
						  layer.msg("密码不一致", {
								time : 10000
							//两秒延迟
							});
					}else {
							 //ajax请求实现访问控制器
								$.ajax({
									type : "put", //提交方式
									url : "${pageContext.request.contextPath}/manager/update", ////地址和springmvc中控制器地址一致
									data : JSON.stringify({
										managerId:"${manager.managerId}",
										managerPwd:$("#password3").val()
									}), //提交给控制器的数据
									contentType : "application/json", //提交给控制的数据 格式
									dataType:"json",
									success : function(cm) {
										layer.msg(cm.msg);
									}
								});
						    return false;
					}
				}else {
					layer.msg("密码与原密码相同", {
						time : 10000
					});
				}
			}else {
				layer.msg("密码错误", {
					time : 10000
				});
			  
			}
			 
		  }); */
		  
		});
		
	</script>
	</body>
</html>